package com.xiaocz.hblsubstitutedriving.adapter;

import android.support.v4.content.ContextCompat;
import android.view.View;
import android.widget.TextView;

import com.xiaocz.common.widgets.recycler.RecyclerViewAdapter;
import com.xiaocz.hblsubstitutedriving.R;
import com.xiaocz.hblsubstitutedriving.model.OrderPrice;
import com.xiaocz.hblsubstitutedriving.model.WithDrawDeposit;


/**
 * Author:  xiaocz.
 * Date:    2018/05.04.
 * Descr:  名片-计费标准
 */
public class PriceListAdapter extends RecyclerViewAdapter<OrderPrice> {

    public PriceListAdapter(AdapterListener<OrderPrice> adapterListener) {
        super(adapterListener);
    }

    @Override
    protected int getItemViewType(int position, OrderPrice data) {
        return R.layout.item_price;
    }

    @Override
    protected ViewHolder<OrderPrice> getViewHolder(View view, int viewType) {
        return new InfoTypeViewHolder(view);
    }

    private static class InfoTypeViewHolder extends ViewHolder<OrderPrice> {

        private TextView tvTitle, tv_time_start, tv_time_end,tv_qb,tv_qb_price,tv_wait_time_price;

        InfoTypeViewHolder(View itemView) {
            super(itemView);
            tvTitle = itemView.findViewById(R.id.tv_title);
            tv_time_start = itemView.findViewById(R.id.tv_time_start);
            tv_time_end = itemView.findViewById(R.id.tv_time_end);
            tv_qb = itemView.findViewById(R.id.tv_qb);
            tv_qb_price = itemView.findViewById(R.id.tv_qb_price);
            tv_wait_time_price = itemView.findViewById(R.id.tv_wait_time_price);
        }

        @Override
        protected void onBind(OrderPrice data, int position) {
            tvTitle.setText(mContext.getResources().getStringArray(R.array.expense_standard)[position]);
            tv_time_start.setText(data.getQishitime());
            tv_time_end.setText(data.getJieshutime());
            tv_qb.setText(String.format("%sKM",data.getQibukm()));
            tv_qb_price.setText(String.format("%s元",data.getQibuprice()));
            tv_wait_time_price.setText(String.format("每%sKM/%s元",data.getChaokm(),data.getChaochuprice()));
        }

        @Override
        public boolean isNeedClick() {
            return true;
        }
    }
}